package com.andy.common.servlet;

import com.andy.base.http.AssembleHttpUtil;
import com.andy.base.servlet.HttpServlet;
import com.andy.base.servlet.Request;
import com.andy.base.servlet.Response;

public class CommonServlet extends HttpServlet {

    public void init() throws Exception {

    }

    public void destory() throws Exception {

    }

    public void doGet(Request request, Response response) {
        doPost(request,response);
    }

    public void doPost(Request request, Response response) {
        System.out.println("method:"+request.getMethod());
        System.out.println("url:"+request.getUrl());

        try {
            String date = "Hello world, url:"+request.getUrl()+"; method="+request.getMethod();
            String responseStr = AssembleHttpUtil.success(date);
            response.output(responseStr);
        } catch (Exception e){
            e.printStackTrace();
        }

    }
}
